//
//  TabBarController.m
//  PocketTutor
//
//  Created by jarze on 15/6/9.
//  Copyright (c) 2015年 jarze. All rights reserved.
//

#import "TabBarController.h"

#import "NavigationController.h"

#import "MeViewController.h"
#import "CourseViewController.h"
#import "UIImage+Extension.h"

#define PTColor(r,g,b,a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)]


@interface TabBarController ()

@end

@implementation TabBarController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    [self ChildVC:self.viewControllers[0] title:@"Records" imageName:@"ico_calendar_normal" selectedImageName:@"ico_calendar_pressed"];
    
    [self ChildVC:self.viewControllers[1] title:@"Courses" imageName:@"ico_courses_normal" selectedImageName:@"ico_courses_pressed"];

    [self ChildVC:self.viewControllers[2]  title:@"My Profile" imageName:@"ico_user_normal" selectedImageName:@"ico_user_pressed"];


    
}
- (void)ChildVC:(UIViewController *)ChildVC title:(NSString *)title imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName
{
    ChildVC.title = title;
    //ChildVC.tabBarItem.title = title;
    ChildVC.navigationItem.title = title;
    
    //图片渲染类型
    ChildVC.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];;
    ChildVC.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImageName]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    //设置字体的颜色
    UITabBarItem *appearance = [UITabBarItem appearance];
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    textAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:10];
    textAttrs[NSForegroundColorAttributeName] = PTColor(64, 66, 74,1);
    [appearance setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
    NSMutableDictionary *selectedTextAttrs = [NSMutableDictionary dictionary];
    selectedTextAttrs[NSForegroundColorAttributeName] = PTColor(224, 60, 70, 1);
    [appearance setTitleTextAttributes:selectedTextAttrs forState:UIControlStateSelected];
    
    //  self.tabBarController.tabBar.barTintColor = PTColor(17, 18, 24, 1.0);
    [self.tabBar setBarTintColor:PTColor(17, 18, 24, 1.0)];
    
//    self.navigationController.tabBarItem.title = title;
//    
//    NavigationController *nav = [[NavigationController alloc] initWithRootViewController:ChildVC];
//    
//      nav.tabBarItem.title = title;
//    
//    
//    [self addChildViewController:nav];
}



@end
